package com.laiketui.admin.store;

import org.springframework.util.FileCopyUtils;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class GetWars {

    public static void main(String[] args) throws IOException {
        System.out.println("start!!");

        String root = System.getProperty("user.dir");
        Map<String,String> pathsMap  = new HashMap<String,String>();

        pathsMap.put("admin.war","laike-admin-store/target/admin.war");
        pathsMap.put("app.war","laike-app/target/app.war");
        pathsMap.put("coupon.war","laike-plugin-coupon/target/coupon.war");
        pathsMap.put("file.war","laike-file/target/file.war");
        pathsMap.put("gateway.war","laike-gateway/target/gateway.war");
        pathsMap.put("mch.war","laike-mch/target/mch.war");
        pathsMap.put("order.war","laike-order/target/order.war");
        pathsMap.put("product.war","laike-products/target/product.war");
        pathsMap.put("payment.war","laike-payment/target/payment.war");
        pathsMap.put("laike-task.war","laike-task/target/laike-task.war");
        pathsMap.put("user.war","laike-user/target/user.war");
        pathsMap.put("mall.war","laike-store-pc/target/mall.war");
        pathsMap.put("admin-mch.war","laike-admin-mch/target/admin-mch.war");
        pathsMap.put("distribute.war","laike-plugin-distribution/target/distribute.war");
        pathsMap.put("freight.war","laike-freight/target/freight.war");
        pathsMap.put("invoice.war","laike-invoice/target/invoice.war");
        pathsMap.put("supplier.war","laike-admin-supplier/target/supplier.war");

        pathsMap.put("diy.war","laike-plugin-diy/target/diy.war");
        pathsMap.put("member.war","laike-plugin-member/target/member.war");
        pathsMap.put("integral.war","laike-plugin-integral/target/integral.war");
        pathsMap.put("presell.war","laike-plugin-presell/target/presell.war");
        pathsMap.put("seckill.war","laike-plugin-seckill/target/seckill.war");
        pathsMap.put("auction.war","laike-plugin-auction/target/auction.war");
        pathsMap.put("group.war","laike-plugin-group/target/group.war");

        String toPaht = "laike-admin-store/src/test/java/com/laiketui/admin/store/";
        
        File tofile = null;
        File fromfile = null;
        Set<String> modulepaths = pathsMap.keySet();
        for (String modulepath :modulepaths ) {
            fromfile = new File(root + "/" + pathsMap.get(modulepath));
            if(fromfile.exists()){
                tofile = new File(root + "/" + toPaht+"/wars/" + modulepath);
                FileCopyUtils.copy(fromfile,tofile);
                System.out.println("获取： " + fromfile.getName()+" 成功！");
            }
        }

        System.out.println("success!!");
    }


}
